package com.lty.bio.demo1;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Client {
	public static void main(String[] args) {
		Socket socket = null;
		OutputStream os = null;
		try {
			socket = new Socket("127.0.0.1", 15600);
			os = socket.getOutputStream();
		} catch (UnknownHostException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		OutputStreamWriter osw = new OutputStreamWriter(os);
		BufferedWriter bw = new BufferedWriter(osw);
		Scanner sc = new Scanner(System.in);// 获取输入内容
		while (sc.hasNext()) {
			String str = sc.nextLine();
			try {
				bw.write(str); // 发送当前时间的字符串
				bw.newLine(); // 需要换行符做readLine()
				bw.flush();
				// Thread.sleep(1000);
			} catch (Exception e) {
				System.out.println("Connection Close");
				break;
			}
		}
	}
}
